﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using eschoolBO;

namespace ESCHOOL.students
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        attend at = new attend();
        subject sub = new subject();
        student stud = new student();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                for (int i = DateTime.Now.Year; i > 1950; i--)
                  ddyear.Items.Add(i.ToString());
                
                

            }
        }

        protected void btnview_Click(object sender, EventArgs e)
        {
            //DataTable dt1 = stud.GetRecords(Convert.ToInt64(Session["userid"]), "", -99, -99, "", "", "", "", "", "", -99, -99, "", -99, "", "","","", false, " and ");
            //DataTable dt2 = at.GetRecords(-99, "", -99, Convert.ToInt64(dt1.Rows[0]["student_id"].ToString()), "", "", false, false, " and ");
            DataTable dt3 = at.GetAtt(Convert.ToInt64(Session["userid"]), ddyear.SelectedValue.ToString(), false, " and ");
            if (dt3.Rows.Count > 0)
            {
                string a = dt3.Rows[0]["absent"].ToString();
                string p = dt3.Rows[0]["present"].ToString();
                GridView1.DataSource = dt3;
                GridView1.DataBind();
            }
            else
            {
                Label1.Visible = true;
                Label1.Text = "No record found.";
            }
        }
        public int getabsent(string abs)
        {
            int no;
            if (abs == "")
                no = 0;
            else
                no = Convert.ToInt32(abs.ToString());
            return no;
        }
        public int getpresent(string pre)
        {
            int no;
            if (pre == "")
                no = 0;
            else
                no = Convert.ToInt32(pre.ToString());
            return no;
        }
        public string getMonth(string month)
        {
            int mn = Convert.ToInt32(month);
            string[] arrMonth = {"","Jan","Feb","March","April","May","Jun","July","Aug","Sept","Oct","Nov","Dec" };
            return arrMonth[mn];
        }
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }

        protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
        {
        //    DateTime dat = new DateTime(Convert.ToInt32(DropDownList3.SelectedItem),Convert.ToInt32(DropDownList2.SelectedValue.ToString()),Convert.ToInt32(1));
        //    //string dm = dat.Month.ToString();
        //    //string dy = dat.Year.ToString();
        //    DataTable dt2 = at.GetRecords(-99, dat.ToString(), -99, -99, -99, "", "", false, false, " and ");
        //    GridView1.DataSource = dt2;
        //    GridView1.DataBind();
        }
    }
}